﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LifeFlow.Servicer.Example.Models;

namespace LifeFlow.Servicer.Example.Controllers
{
    public partial class UserController
    {
        public class Version1_0 : Controller
        {
            /// <summary>
            /// Returns a user by ID (The user is actually hard-coded)
            /// </summary>
            /// <returns>A user</returns>
            [Service(Service = "User", Action = "GetUserByID", MaxVersion = "1.0")]
            public ActionResult GetUserByID()
            {
                return Json(new User()
                {
                    Username = "mortenolsen",
                    Email = "contact@mortenolsen.net"
                }, JsonRequestBehavior.AllowGet);
            }

            /// <summary>
            /// Returnes the inputed string
            /// </summary>
            /// <param name="name" type="string">The string to return</param>
            /// <returns>The input string</returns>
            [Service(Service = "User", Action = "GetNameBack")]
            public string GetNameBack()
            {
                return ServiceParameter.GetParameter<string>("Name");
            }

            /// <summary>
            /// Returnes the inputed string, if key is valid
            /// </summary>
            /// <param name="name" type="string">The string to return</param>
            /// <returns>The input string</returns>
            [Service(Service = "User", Action = "GetNameBackKeyed", RequireKey = true)]
            public string GetNameBackKeyed()
            {
                return ServiceParameter.GetParameter<string>("Name");
            }
        }
    }
}